package com.wwwarehouse.resource_center.fragment.defindeobjectstore;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSON;
import com.wwwarehouse.common.activity.base.BaseFragment;
import com.wwwarehouse.common.bean.response.CommonClass;
import com.wwwarehouse.common.custom_widget.button.StateButton;
import com.wwwarehouse.common.custom_widget.state_layout.StateLayout;
import com.wwwarehouse.common.custom_widget.time_pick.ChoosePickerDialog;
import com.wwwarehouse.common.http.NoHttpUtils;
import com.wwwarehouse.common.tools.LogUtils;
import com.wwwarehouse.resource_center.R;
import com.wwwarehouse.resource_center.bean.defindeobjectstore.DefineOkBean;
import com.wwwarehouse.resource_center.bean.defindeobjectstore.DefinedDetailBean;
import com.wwwarehouse.resource_center.bean.defindeobjectstore.DefinedObjectStoreBean;
import com.wwwarehouse.resource_center.constant.ResourceConstant;
import com.wwwarehouse.resource_center.eventbus_event.DefineEvent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import de.greenrobot.event.EventBus;

import static com.wwwarehouse.resource_center.R.id.defined_deal_system_storein_lin;
import static com.wwwarehouse.resource_center.R.id.defined_deal_system_storeout_lin;
import static com.wwwarehouse.resource_center.R.id.defined_deal_system_titletxt;

/**
 * Description: 定义实物库存第一个页面
 * Copyright  : Copyright (c) 2017
 * Author     : minifly
 * Date       : 2017/10/25
 * <p>
 * type :  INVENTORY_DEFINITION
 */
@Route(path = "/ResourceObjec/DefinedObjectAllobjectFragment")
public class DefinedObjectDealFragment extends BaseFragment implements View.OnClickListener, TextWatcher {

    private View v;
    private TextView mDefinedDealSystemTitletxt;
    private StateButton mDefinedDealSystemManageBtn1;
    private StateButton mDefinedDealSystemManageBtn2;
    private StateButton mDefinedDealSystemManageBtn3;
    private TextView mDefinedDealSystemStoreinTxt;
    private LinearLayout mDefinedDealSystemStoreinLin;
    private TextView mDefinedDealSystemStoreoutTxt;
    private LinearLayout mDefinedDealSystemStoreoutLin;
    private StateButton mDefinedDealSystemStoreqaulityBtn1;
    private StateButton mDefinedDealSystemStoreqaulityBtn2;
    private StateButton mDefinedDealSystemStoreqaulityBtn3;
    private StateButton mDefinedDealSystemStoreprivaledgeBtn1;
    private StateButton mDefinedDealSystemStoreprivaledgeBtn2;
    private ImageView mDefinedDealSystemCountnomesImg;
    private LinearLayout mDefinedDealSystemCountnomesLin;
    private StateButton mDefinedDealSystemRestoresysBtn;
    private StateButton mDefinedDealSystemDefinedokBtn;
    private StateLayout mDefinedDealSystemStatelayout;
    private Map<String, Object> mMap;
    private List<String> mInventoryProxyMy;
    private List<String> mQualityMy;
    private List<String> mInventoryPropertyRightMy;
    private String mInTheStock;
    private String mOutsideTheStock;
    private List<String> mInventoryProxy;
    private List<String> mQuality;
    private List<String> mInventoryPropertyRight;
    private String mCountUnknowInventory;
    private ArrayList<String> mInWarePlaceList;
    private ArrayList<String> mOutWarePlaceList;
    private long mOwnerUkid;
    private long mInventoryDefinitionUkid;
    private String mName;
    private String mName1;
    //    private long                 mOwnerUkid1;
    private String mDefaultInventory;
    private long mBusinessUnitUkid;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        v = inflater.inflate(R.layout.fragment_defined_object_dealpage, container, false);
        initView(v);
        initEvent();
        return v;
    }

    @Override
    public void setTitle() {
        if (peekFragment() instanceof DefinedObjectDealFragment)
            mActivity.setTitle("" + getString(R.string.defined_object_store_title));
    }

    @Override
    public void requestDatas() {
        mInWarePlaceList = new ArrayList<>();
        mInWarePlaceList.add("--");
        mInWarePlaceList.add(mActivity.getResources().getString(R.string.defined_object_store_qaulity_dontknow));
        mInWarePlaceList.add(mActivity.getResources().getString(R.string.defined_object_defined_any));
        mOutWarePlaceList = new ArrayList<>();
        mOutWarePlaceList.add(mActivity.getResources().getString(R.string.on_way));
        mOutWarePlaceList.add("--");
        mOutWarePlaceList.add(mActivity.getResources().getString(R.string.defined_object_store_qaulity_dontknow));
        mOutWarePlaceList.add(mActivity.getResources().getString(R.string.defined_object_defined_any));
        if (getArguments() != null && getArguments().getParcelable("listBean") != null) {
            DefinedObjectStoreBean.ListBean listBean = getArguments().getParcelable("listBean");
            mBusinessUnitUkid = getArguments().getLong("businessUnitUkid");
            //            mOwnerUkid1 = listBean.getOwnerUkid();
            mName1 = listBean.getName();
            mMap = new HashMap<>();
            mMap.put("businessUnitUkid", mBusinessUnitUkid);
            mMap.put("name", mName1);
            mMap.put("recoveryDefault", "0");
            getDetailMsg();
        }
        //库存管理方集合
        mInventoryProxyMy = new ArrayList<>();
        //库存品质
        mQualityMy = new ArrayList<>();
        //库存产权
        mInventoryPropertyRightMy = new ArrayList<>();
    }

    private void getDetailMsg() {
        mDefinedDealSystemStatelayout.showProgressView(true);
        NoHttpUtils.httpPost(ResourceConstant.GET_INVENTORY_DETAIL, mMap, mOnResponseListener, 0);
    }

    private NoHttpUtils.OnResponseListener mOnResponseListener = new NoHttpUtils.OnResponseListener() {
        @Override
        public void onSucceed(CommonClass commonClass, int i) {
            try {
                if ("0".equals(commonClass.getCode())) {
                    switch (i) {
                        case 0:
                            DefinedDetailBean definedDetailBean = JSON.parseObject(commonClass.getData().toString(), DefinedDetailBean.class);
                            mName = definedDetailBean.getName();
                            mDefinedDealSystemTitletxt.setText(String.format(mActivity.getResources().getString(R.string.invite_name), definedDetailBean.getName()));
                            //库存管理方集合
                            mInventoryProxy = definedDetailBean.getInventoryProxy();
                            //仓内位置
                            mInTheStock = definedDetailBean.getInTheStock();
                            //仓外位置
                            mOutsideTheStock = definedDetailBean.getOutsideTheStock();
                            //库存品质
                            mQuality = definedDetailBean.getQuality();
                            //库存产权
                            mInventoryPropertyRight = definedDetailBean.getInventoryPropertyRight();
                            //是否统计未知数量库存	string	0 否 1是
                            mCountUnknowInventory = definedDetailBean.getCountUnknowInventory();


                            String defaultInventory = definedDetailBean.getDefaultInventory();//是否默认库存	string	0 否 1是
                            //库存id	number
                            mInventoryDefinitionUkid = definedDetailBean.getInventoryDefinitionUkid();
                            //业务单位id	number
                            mOwnerUkid = definedDetailBean.getOwnerUkid();
                            changeView();
                            break;
                        case 1:
                            popFragment();
                            DefineEvent defineEvent = new DefineEvent();
                            defineEvent.setFinish(true);
                            EventBus.getDefault().post(defineEvent);
                            break;
                        case 2:
                            DefinedDetailBean definedDetailBean1 = JSON.parseObject(commonClass.getData().toString(), DefinedDetailBean.class);
                            mName = definedDetailBean1.getName();
                            mDefinedDealSystemTitletxt.setText(String.format(mActivity.getResources().getString(R.string.invite_name), definedDetailBean1.getName()));
                            //库存管理方集合
                            mInventoryProxy = definedDetailBean1.getInventoryProxy();
                            //仓内位置
                            mInTheStock = definedDetailBean1.getInTheStock();
                            //仓外位置
                            mOutsideTheStock = definedDetailBean1.getOutsideTheStock();
                            //库存品质
                            mQuality = definedDetailBean1.getQuality();
                            //库存产权
                            mInventoryPropertyRight = definedDetailBean1.getInventoryPropertyRight();
                            //是否统计未知数量库存	string	0 否 1是
                            mCountUnknowInventory = definedDetailBean1.getCountUnknowInventory();


                            //是否默认库存	string	0 否 1是
                            mDefaultInventory = definedDetailBean1.getDefaultInventory();
                            //库存id	number
                            mInventoryDefinitionUkid = definedDetailBean1.getInventoryDefinitionUkid();
                            //业务单位id	number
                            mOwnerUkid = definedDetailBean1.getOwnerUkid();
                            changeView();
                            break;
                    }


                }
            } catch (Exception e) {
                LogUtils.showLog(e.toString());
            }
        }

        @Override
        public void onFailed(String s, int i) {
            switch (i) {
                case 0:
                    mDefinedDealSystemStatelayout.showSystemView(true);
                    mDefinedDealSystemStatelayout.setSystemListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            getDetailMsg();
                        }
                    });
                    break;
            }

        }

        @Override
        public void onFinish(int i) {
            switch (i) {
                case 0:
                    mDefinedDealSystemStatelayout.showContentView();
                    break;
                case 1:
                    dismissProgressDialog();
                    break;
                case 2:
                    dismissProgressDialog();
                    break;
            }
        }
    };

    private void changeView() {

        if (mInventoryProxy != null && mInventoryProxy.size() > 0) {
            for (int i = 0; i < mInventoryProxy.size(); i++) {
                if (mActivity.getResources().getString(R.string.defined_object_store_bu).equals(mInventoryProxy.get(i))) {
                    setBntSelected(mDefinedDealSystemManageBtn1);
                    isManage1 = true;
                } else if (mActivity.getResources().getString(R.string.defined_object_translate_bu).equals(mInventoryProxy.get(i))) {
                    setBntSelected(mDefinedDealSystemManageBtn2);
                    isManage2 = true;
                }
                if (mActivity.getResources().getString(R.string.defined_object_goods_bu).equals(mInventoryProxy.get(i))) {
                    setBntSelected(mDefinedDealSystemManageBtn3);
                    isManage3 = true;
                }
            }

        }
        if (TextUtils.isEmpty(mInTheStock)) {
            mDefinedDealSystemStoreinTxt.setText(mActivity.getResources().getString(R.string.select_in));
        } else {
            mDefinedDealSystemStoreinTxt.setText(mInTheStock);
        }
        if (TextUtils.isEmpty(mOutsideTheStock)) {
            mDefinedDealSystemStoreoutTxt.setText(mActivity.getResources().getString(R.string.select_out));
        } else {
            mDefinedDealSystemStoreoutTxt.setText(mOutsideTheStock);
        }

        if (mQuality != null && mQuality.size() > 0) {
            for (int i = 0; i < mQuality.size(); i++) {
                if (mActivity.getResources().getString(R.string.defined_object_store_qaulity_good).equals(mQuality.get(i))) {
                    setBntSelected(mDefinedDealSystemStoreqaulityBtn1);
                    isQaulity1 = true;
                } else if (mActivity.getResources().getString(R.string.defined_object_store_qaulity_bad).equals(mQuality.get(i))) {
                    setBntSelected(mDefinedDealSystemStoreqaulityBtn2);
                    isQaulity2 = true;
                }
                if (mActivity.getResources().getString(R.string.defined_object_store_qaulity_dontknow).equals(mQuality.get(i))) {
                    setBntSelected(mDefinedDealSystemStoreqaulityBtn3);
                    isQaulity3 = true;
                }
            }
        }

        if (mInventoryPropertyRight != null && mInventoryPropertyRight.size() > 0) {
            for (int i = 0; i < mInventoryPropertyRight.size(); i++) {
                if (mActivity.getResources().getString(R.string.defined_object_store_right_rent).equals(mInventoryPropertyRight.get(i))) {
                    setBntSelected(mDefinedDealSystemStoreprivaledgeBtn1);
                    isPower1 = true;
                } else if (mActivity.getResources().getString(R.string.defined_object_store_rent_change).equals(mInventoryPropertyRight.get(i))) {
                    setBntSelected(mDefinedDealSystemStoreprivaledgeBtn2);
                    isPower2 = true;
                }
            }
        }
        if ("1".equals(mCountUnknowInventory)) {
            mDefinedDealSystemCountnomesImg.setImageResource(R.drawable.checkbox);
            isSelected = true;
        } else {
            mDefinedDealSystemCountnomesImg.setImageResource(R.drawable.icon_defined_object_selectno);
            isSelected = false;
        }
        isEnable();

    }

    private boolean isManage1;
    private boolean isManage2;
    private boolean isManage3;
    private boolean isQaulity1;
    private boolean isQaulity2;
    private boolean isQaulity3;
    private boolean isPower1;
    private boolean isPower2;
    private boolean isSelected;

    @Override
    public void onClick(View v) {
        int i = v.getId();

        if (i == R.id.defined_deal_system_manage_btn1) {
            if (!isManage1) {
                setBntSelected(mDefinedDealSystemManageBtn1);
            } else {
                setBntNormal(mDefinedDealSystemManageBtn1);
            }
            isManage1 = !isManage1;
        } else if (i == R.id.defined_deal_system_manage_btn2) {
            if (!isManage2) {
                setBntSelected(mDefinedDealSystemManageBtn2);
            } else {
                setBntNormal(mDefinedDealSystemManageBtn2);
            }
            isManage2 = !isManage2;
        } else if (i == R.id.defined_deal_system_manage_btn3) {
            if (!isManage3) {
                setBntSelected(mDefinedDealSystemManageBtn3);
            } else {
                setBntNormal(mDefinedDealSystemManageBtn3);
            }
            isManage3 = !isManage3;
        } else if (i == defined_deal_system_storein_lin) {
            showEndPop(mActivity.getResources().getString(R.string.defined_object_store_place), mInWarePlaceList, mDefinedDealSystemStoreinTxt);
        } else if (i == defined_deal_system_storeout_lin) {
            showEndPop(mActivity.getResources().getString(R.string.defined_object_store_out_place), mOutWarePlaceList, mDefinedDealSystemStoreoutTxt);
        } else if (i == R.id.defined_deal_system_storeqaulity_btn1) {
            if (!isQaulity1) {
                setBntSelected(mDefinedDealSystemStoreqaulityBtn1);
            } else {
                setBntNormal(mDefinedDealSystemStoreqaulityBtn1);
            }
            isQaulity1 = !isQaulity1;
        } else if (i == R.id.defined_deal_system_storeqaulity_btn2) {
            if (!isQaulity2) {
                setBntSelected(mDefinedDealSystemStoreqaulityBtn2);
            } else {
                setBntNormal(mDefinedDealSystemStoreqaulityBtn2);
            }
            isQaulity2 = !isQaulity2;
        } else if (i == R.id.defined_deal_system_storeqaulity_btn3) {
            if (!isQaulity3) {
                setBntSelected(mDefinedDealSystemStoreqaulityBtn3);
            } else {
                setBntNormal(mDefinedDealSystemStoreqaulityBtn3);
            }
            isQaulity3 = !isQaulity3;
        } else if (i == R.id.defined_deal_system_storeprivaledge_btn1) {
            if (!isPower1) {
                setBntSelected(mDefinedDealSystemStoreprivaledgeBtn1);
            } else {
                setBntNormal(mDefinedDealSystemStoreprivaledgeBtn1);
            }
            isPower1 = !isPower1;
        } else if (i == R.id.defined_deal_system_storeprivaledge_btn2) {
            if (!isPower2) {
                setBntSelected(mDefinedDealSystemStoreprivaledgeBtn2);
            } else {
                setBntNormal(mDefinedDealSystemStoreprivaledgeBtn2);
            }
            isPower2 = !isPower2;
        } else if (i == R.id.defined_deal_system_countnomes_img) {
            if (!isSelected) {
                mDefinedDealSystemCountnomesImg.setImageResource(R.drawable.checkbox);
                mCountUnknowInventory = "1";
            } else {
                mDefinedDealSystemCountnomesImg.setImageResource(R.drawable.icon_defined_object_selectno);
                mCountUnknowInventory = "0";
            }
            isSelected = !isSelected;
        } else if (i == R.id.defined_deal_system_restoresys_btn) {
            setAllNormal();
            resertAll();
        } else if (i == R.id.defined_deal_system_definedok_btn) {
            defineFinish();
        }
        isEnable();
    }

    private void resertAll() {
        if (getArguments() != null && getArguments().getParcelable("listBean") != null) {
            mMap.put("businessUnitUkid", mBusinessUnitUkid);
            mMap.put("name", mName1);
            mMap.put("recoveryDefault", "1");
            showProgressDialog();
            NoHttpUtils.httpPost(ResourceConstant.GET_INVENTORY_DETAIL, mMap, mOnResponseListener, 2);
        }
        //库存管理方集合
        mInventoryProxyMy.clear();
        //库存品质
        mQualityMy.clear();
        //库存产权
        mInventoryPropertyRightMy.clear();
    }

    private void defineFinish() {

        Map<String, Object> defineFinishMap = new HashMap<>();
        defineFinishMap.put("businessUnitUkid", mBusinessUnitUkid);
        DefineOkBean defineOkBean = new DefineOkBean();
        defineOkBean.setCountUnknowInventory(mCountUnknowInventory);//是否统计未知数量库存 0 否 1是
        if (mActivity.getResources().getString(R.string.select_in).equals(mDefinedDealSystemStoreinTxt.getText().toString().trim())) {
            defineOkBean.setInTheStock("");
        } else {
            defineOkBean.setInTheStock(mDefinedDealSystemStoreinTxt.getText().toString().trim());//仓内位置
        }
        defineOkBean.setInventoryDefinitionUkid(mInventoryDefinitionUkid);//库存id 不传表示新增自定义非默认库存定义，传则是修改库存定义
        if (isManage1) {
            mInventoryProxyMy.add(mActivity.getResources().getString(R.string.defined_object_store_bu));
        }
        if (isManage2) {
            mInventoryProxyMy.add(mActivity.getResources().getString(R.string.defined_object_translate_bu));
        }
        if (isManage3) {
            mInventoryProxyMy.add(mActivity.getResources().getString(R.string.defined_object_goods_bu));
        }
        defineOkBean.setInventoryProxy(mInventoryProxyMy);//库存管理方数组

        if (isPower1) {
            mInventoryPropertyRightMy.add(mActivity.getResources().getString(R.string.defined_object_store_right_rent));
        }
        if (isPower2) {
            mInventoryPropertyRightMy.add(mActivity.getResources().getString(R.string.defined_object_store_rent_change));
        }
        defineOkBean.setInventoryPropertyRight(mInventoryPropertyRightMy);//库存产权数组

        defineOkBean.setName(mName);//库存名字
        if (mActivity.getResources().getString(R.string.select_out).equals(mDefinedDealSystemStoreoutTxt.getText().toString().trim())) {
            defineOkBean.setOutsideTheStock("");
        } else {
            defineOkBean.setOutsideTheStock(mDefinedDealSystemStoreoutTxt.getText().toString().trim());//仓外位置
        }
        defineOkBean.setOwnerUkid(mOwnerUkid);//库存定义的拥有者
        if (isQaulity1) {
            mQualityMy.add(mActivity.getResources().getString(R.string.defined_object_store_qaulity_good));
        }
        if (isQaulity2) {
            mQualityMy.add(mActivity.getResources().getString(R.string.defined_object_store_qaulity_bad));
        }
        if (isQaulity3) {
            mQualityMy.add(mActivity.getResources().getString(R.string.defined_object_store_qaulity_dontknow));
        }
        defineOkBean.setQuality(mQualityMy);
        defineFinishMap.put("param", defineOkBean);
        showProgressDialog();
        NoHttpUtils.httpPost(ResourceConstant.UPDATA_OR_SAVE_INVENT, defineFinishMap, mOnResponseListener, 1);
    }

    private void showEndPop(final String s, final ArrayList<String> list, final TextView textView) {
        new ChoosePickerDialog.Builder(mActivity).setData(list).setTitle(s).setOnDataSelectedListener(new ChoosePickerDialog.OnSelectedListener() {
            @Override
            public void onSelected(String itemValue, int position) {
                if ("--".equals(list.get(position))) {
                    if (mActivity.getResources().getString(R.string.defined_object_store_place).equals(s)) {
                        textView.setText(mActivity.getResources().getString(R.string.select_in));
                    } else if (mActivity.getResources().getString(R.string.defined_object_store_out_place).equals(s)) {
                        textView.setText(mActivity.getResources().getString(R.string.select_out));
                    }
                } else {
                    textView.setText(list.get(position));
                }
            }

            @Override
            public void onCancel() {

            }
        }).create().show();
    }

    private void setAllNormal() {
        setBntNormal(mDefinedDealSystemManageBtn1);
        setBntNormal(mDefinedDealSystemManageBtn2);
        setBntNormal(mDefinedDealSystemManageBtn3);
        setBntNormal(mDefinedDealSystemStoreqaulityBtn1);
        setBntNormal(mDefinedDealSystemStoreqaulityBtn2);
        setBntNormal(mDefinedDealSystemStoreqaulityBtn3);
        setBntNormal(mDefinedDealSystemStoreprivaledgeBtn1);
        setBntNormal(mDefinedDealSystemStoreprivaledgeBtn2);
        mDefinedDealSystemCountnomesImg.setImageResource(R.drawable.icon_defined_object_selectno);
        //        mDefinedDealSystemCountnomesImg.setBackground(mActivity.getResources().getDrawable(R.drawable.icon_defined_object_selectno));
        mDefinedDealSystemDefinedokBtn.setEnabled(false);
    }

    private void setBntNormal(StateButton stateButton) {
        stateButton.setNormalTextColor(mActivity.getResources().getColor(R.color.common_color_c8_d5d7dc));
        stateButton.setNormalStrokeColor(mActivity.getResources().getColor(R.color.common_color_c8_d5d7dc));
        stateButton.setPressedTextColor(mActivity.getResources().getColor(R.color.common_color_c8_d5d7dc));
        stateButton.setPressedStrokeColor(mActivity.getResources().getColor(R.color.common_color_c8_d5d7dc));
    }

    private void setBntSelected(StateButton stateButton) {
        stateButton.setNormalTextColor(mActivity.getResources().getColor(R.color.common_color_c1_337cff));
        stateButton.setNormalStrokeColor(mActivity.getResources().getColor(R.color.common_color_c1_337cff));
        stateButton.setPressedTextColor(mActivity.getResources().getColor(R.color.common_color_c1_337cff));
        stateButton.setPressedStrokeColor(mActivity.getResources().getColor(R.color.common_color_c1_337cff));
    }

    private void isEnable() {
        if ((isManage1 || isManage2 || isManage3) &&
                (isQaulity1 || isQaulity2 || isQaulity3) &&
                ((!mActivity.getResources().getString(R.string.select_in).equals(mDefinedDealSystemStoreinTxt.getText().toString().trim())) || !mActivity.getResources().getString(R.string.select_out).equals(mDefinedDealSystemStoreoutTxt.getText().toString().trim()))) {
            mDefinedDealSystemDefinedokBtn.setEnabled(true);
        } else {
            mDefinedDealSystemDefinedokBtn.setEnabled(false);
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        isEnable();
    }

    @Override
    public void afterTextChanged(Editable s) {

    }

    private void initView(View v) {
        mDefinedDealSystemTitletxt = (TextView) v.findViewById(defined_deal_system_titletxt);
        mDefinedDealSystemManageBtn1 = (StateButton) v.findViewById(R.id.defined_deal_system_manage_btn1);
        mDefinedDealSystemManageBtn2 = (StateButton) v.findViewById(R.id.defined_deal_system_manage_btn2);
        mDefinedDealSystemManageBtn3 = (StateButton) v.findViewById(R.id.defined_deal_system_manage_btn3);
        mDefinedDealSystemStoreinTxt = (TextView) v.findViewById(R.id.defined_deal_system_storein_txt);
        mDefinedDealSystemStoreinTxt.addTextChangedListener(this);
        mDefinedDealSystemStoreinLin = (LinearLayout) v.findViewById(defined_deal_system_storein_lin);
        mDefinedDealSystemStoreoutTxt = (TextView) v.findViewById(R.id.defined_deal_system_storeout_txt);
        mDefinedDealSystemStoreoutLin = (LinearLayout) v.findViewById(defined_deal_system_storeout_lin);
        mDefinedDealSystemStoreoutTxt.addTextChangedListener(this);
        mDefinedDealSystemStoreqaulityBtn1 = (StateButton) v.findViewById(R.id.defined_deal_system_storeqaulity_btn1);
        mDefinedDealSystemStoreqaulityBtn2 = (StateButton) v.findViewById(R.id.defined_deal_system_storeqaulity_btn2);
        mDefinedDealSystemStoreqaulityBtn3 = (StateButton) v.findViewById(R.id.defined_deal_system_storeqaulity_btn3);
        mDefinedDealSystemStoreprivaledgeBtn1 = (StateButton) v.findViewById(R.id.defined_deal_system_storeprivaledge_btn1);
        mDefinedDealSystemStoreprivaledgeBtn2 = (StateButton) v.findViewById(R.id.defined_deal_system_storeprivaledge_btn2);
        mDefinedDealSystemCountnomesImg = (ImageView) v.findViewById(R.id.defined_deal_system_countnomes_img);
        mDefinedDealSystemCountnomesLin = (LinearLayout) v.findViewById(R.id.defined_deal_system_countnomes_lin);
        mDefinedDealSystemRestoresysBtn = (StateButton) v.findViewById(R.id.defined_deal_system_restoresys_btn);
        mDefinedDealSystemDefinedokBtn = (StateButton) v.findViewById(R.id.defined_deal_system_definedok_btn);
        mDefinedDealSystemStatelayout = (StateLayout) v.findViewById(R.id.defined_deal_system_statelayout);
    }

    private void initEvent() {
        mDefinedDealSystemManageBtn1.setOnClickListener(this);
        mDefinedDealSystemManageBtn2.setOnClickListener(this);
        mDefinedDealSystemManageBtn3.setOnClickListener(this);
        mDefinedDealSystemStoreinLin.setOnClickListener(this);
        mDefinedDealSystemStoreoutLin.setOnClickListener(this);
        mDefinedDealSystemStoreqaulityBtn1.setOnClickListener(this);
        mDefinedDealSystemStoreqaulityBtn2.setOnClickListener(this);
        mDefinedDealSystemStoreqaulityBtn3.setOnClickListener(this);
        mDefinedDealSystemStoreprivaledgeBtn1.setOnClickListener(this);
        mDefinedDealSystemStoreprivaledgeBtn2.setOnClickListener(this);
        mDefinedDealSystemCountnomesImg.setOnClickListener(this);
        mDefinedDealSystemRestoresysBtn.setOnClickListener(this);
        mDefinedDealSystemDefinedokBtn.setOnClickListener(this);
    }
}
